<?php
require 'db.php';
$id=  isset($_GET['id'])?$_GET['id']:0;
if (empty($_POST)){
$sp=$db->query("select * from t_message where id='{$id}'");
$rs=$sp->fetch_array();
require 'edit_index.php';
}  else {
$username=$_POST['username'];
$sex=$_POST['sex'];
$message=$_POST['message'];
$imgurl=$_POST['imgurl'];
date_default_timezone_set("Asia/Shanghai");
$m_date=  date('Y/m/d   H:i:s');
$sp="update t_message set username='$username',sex='$sex',message='$message',imgurl='$imgurl' where e_id='$id'";
$rs=$db->query($sp);
if($rs){
   echo '<script anguage="javascript">';
    echo 'alert("成功了！");';
    echo 'window.location.href="index.php"';
    echo '</script>';
}else{
    echo '<script anguage="javascript">';
    echo 'alert("失败了！");';
    echo 'window.location.href="index.php"';
    echo '</script>';
}
}
$db->close();